﻿namespace OpenAiMobile;

// ReSharper disable once RedundantExtendsListEntry
public partial class App : Application
{
	public App()
	{
		InitializeComponent();

		MainPage = new AppShell();
	}

    protected override async void OnStart()
    {
        var _ = await CheckPermissionsAsync();
        
        await Shell.Current.GoToAsync("//LoginPage");
    }

    private async Task<bool> CheckPermissionsAsync()
    {
        var status = await Permissions.CheckStatusAsync<Permissions.Phone>();
        if (status != PermissionStatus.Granted)
        {
            status = await Permissions.RequestAsync<Permissions.Phone>();
            if (status == PermissionStatus.Denied)
            {
                return false;
            }
        }

        return true;
    }
}
